package com.dh.jarvis.HttpUtil.callback;

import com.dh.jarvis.HttpUtil.HttpResObj;
import com.dh.jarvis.Util.AndroidUtil;
import com.dh.jarvis.Util.DialogUtil;
import com.dh.jarvis.Util.LogUtil;

import okhttp3.Request;
import okhttp3.Response;

/**
 * Created by zhy on 15/12/14.
 */
public abstract class StringCallback extends HttpCallback<String> {

    @Override
    public String parseNetworkResponse(Response response) throws Exception {
        return null;
    }

    @Override
    public void onFailure(HttpResObj resObj) {
        LogUtil.e(resObj.getInfo());
        AndroidUtil.toast(resObj.getInfo());
    }

    @Override
    public void onError(Request request, Exception e) {
        LogUtil.v("onError");
        e.getStackTrace();
    }

    @Override
    public String parseNetworkResponse(HttpResObj resObj) throws Exception {
        LogUtil.v("parseNetworkResponse");
        return resObj.getData().toString();
    }

    @Override
    public void onAfter() {
        LogUtil.v("onAfter");
        DialogUtil.getInstance().dismissLoadingDialog();
    }

    @Override
    public void onBefore() {
        LogUtil.v("onBefore");
    }
}
